package model

import "strconv"

//RawMachine 结构体
type Raw_machine_config struct {
	Tid        int
	Machine_ip string
	Raw_data   []byte
	Dtime      string
}

// 解析 Raw_machine_conf 原始数据
func (r *Raw_machine_config) Interpret() Base_machine {

	var machine = Base_machine{}

	machine.Boot_cond = int((uint16(r.Raw_data[6] << 8)) + uint16(r.Raw_data[7]))
	machine.Boot_delay = int((uint16(r.Raw_data[8] << 8)) + uint16(r.Raw_data[9]))

	//machine.Boot_speed = int((r.Raw_data[12] << 8) + r.Raw_data[13])
	//machine.Boot_mode = int((r.Raw_data[16] << 8) + r.Raw_data[17])

	machine.Spindle_count = int((uint16(r.Raw_data[32]) << 8) + uint16(r.Raw_data[33]))
	machine.Spindle_mode = int(uint16(r.Raw_data[44]<<8) + uint16(r.Raw_data[45]))

	no := strconv.Itoa(int(uint16(r.Raw_data[66]<<8) + uint16(r.Raw_data[67])))
	machine.Machine_no = no

	machine.Machine_ip = r.Machine_ip

	return machine
}
